﻿using System;

namespace Panda.UI.Runtime
{
  
    public interface IPage
    {
        public PageState PageState { get; set; }
        public object Data { get; set; }
        public bool IsPopup { get; }
        public bool IsInInAnim { get; protected set; }
        public bool IsInOutAnim { get; protected set; }
        public IRouter Router { get; set; }
        public IPage SourcePage { get; set; }

        public abstract void Load();
        public abstract void Show(bool fromBack);
        public abstract void Hide();
        public abstract void Cover();
        public abstract void Recover();
        public abstract void Unload();
        public abstract IPage Clone();

    }
    
    [Flags]
    public enum PageState
    {
        Showed = 1 << 0,
        Hided = 1 << 1,
        InInAnim = 1 << 2,
        InOutAnim = 1 << 3,
        Covered = 1 << 4,
    }

    public static class PageStateExtension
    {
        public static bool IsInAnim(this PageState pageState)
        {
            return (pageState & PageState.InInAnim) != 0 || (pageState & PageState.InOutAnim) != 0;
        }
    }

}